// pages/commentdetail/commentdetail.js
const app = getApp() // 引入app
const _request = require("../../utils/request.js"); // 引入require;
import { getitle } from '../../utils/util.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    comment: {},
    pictures:[
      {
        url: "https://kjyiyue.oss-cn-shenzhen.aliyuncs.com/images/header.png"
      },
      {
        url: "https://kjyiyue.oss-cn-shenzhen.aliyuncs.com/images/header.png"
      },
      {
        url: "https://kjyiyue.oss-cn-shenzhen.aliyuncs.com/images/header.png"
      },
      {
        url: "https://kjyiyue.oss-cn-shenzhen.aliyuncs.com/images/header.png"
      },
      {
        url: "https://kjyiyue.oss-cn-shenzhen.aliyuncs.com/images/header.png"
      },
      {
        url: "https://kjyiyue.oss-cn-shenzhen.aliyuncs.com/images/header.png"
      }
    ],
    storeComent: false,
    confirmContent: '',
    serverDesc:"",
    generDesc: "",
    shopevaluate: '',
    serverevaluate: '',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let orderId = options.orderId
    this.getOrderComment(orderId)
  },
  // 查看评价信息
  getOrderComment(orderId) {
    _request.get('/storeComment/getOrderComment', {
      orderId: orderId
    }).then((res) => {
      console.log(res)
      if (res.data.data) {
        let generDesc = '';
        if(res.data.data.gener > 1){  
          generDesc = '女'
        } else {
          generDesc = '男'
        }
        this.setData({
          comment: res.data.data,
          generDesc:generDesc,
          shopevaluate: getitle(res.data.data.storeScore),
          serverevaluate: getitle(res.data.data.server)
        })
      }
    }).catch((error) => {
      console.log(error, 'error');
    })
  },

  onComfirm(event){
    this.setData({
      confirmContent: event.detail.value
    })
  },

  /* 提交 */
  submitComment(){
    console.log(this.data.confirmContent)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})